//维保计划
import {listWbPlan} from "@/api/wb/wbPlan.js"
// 业主公司
import { listWbEntAuth } from "@/api/wb/wbEntAuth.js"
//查询所有维保公司
import { listWbMaintainCompany } from "@/api/wb/wbMaintainCompany.js"
// 合同
import {listWbContract} from "@/api/wb/wbContract.js"
// 师傅
import { listWbMasterEnter } from "@/api/wb/wbMasterEnter.js"
// 问卷标题
import { listTemplate } from "@/api/wb/wbQuestionTitleTemplate.js"
// 维保公司师傅列表
import { listCompanyMaster } from "@/api/wb/userManage.js"
const state = {
    // 维保计划
    planList: [],
    // 业主公司
    componentList: [],
    // 师傅
    masterList: [],
    // 合同
    contractList: [],
    // 维保公司
    maintainCompanyList: [],
    // 问卷标题
    questionTitleList: [],
    // 维保公司师傅列表
    companyMasterList: []
}
const mutations = {
    SET_WB_COMPANY: (state, data) => {
        state.maintainCompanyList = data;
    },
    SET_COMPANY_LIST: (state, data) => {
        state.componentList = data;
    },
    SWT_PLAN_LIST: (state, data) => {
        state.planList = data;
    },
    SET_CONTRACT_LIST: (state, data) => {
        state.contractList = data;
    },
    SET_MASTER_LIST: (state, data) => {
        state.masterList = data;
    },
    SET_QUESTION_TLIST: (state, data) => {
        state.questionTitleList = data;
    },
    SET_COMPANY_MASTERS: (state, data) => {
        state.companyMasterList = data;
    }
}

const actions = {
    getWbList({ commit }, data) {
        listWbMaintainCompany().then(data => {
            commit('SET_WB_COMPANY', data.rows);
        })
    },
    getCompanyList({ commit }, data) {
        listWbEntAuth({state: 1}).then(data => {
            commit('SET_COMPANY_LIST', data.rows);
        })
    },
    getPlanList({ commit }, data) {
        listWbPlan({status: 1}).then(data => {
            commit('SWT_PLAN_LIST', data.rows);
        })
    },
    getContractList({ commit }, data) {
        listWbContract().then(data => {
            commit('SET_CONTRACT_LIST', data.rows);
        })
    },
    getMasterList({ commit }, data) {
        listWbMasterEnter({...data, auditType: 2}).then(data => {
            commit('SET_MASTER_LIST', data.rows);
        })
    },
    getQuestionTitleList({ commit }, data) {
        listTemplate().then(data => {
            commit('SET_QUESTION_TLIST', data.rows);
        })
    },
    getCompanyMasterList({ commit }, data) {
        listCompanyMaster().then(res => {
            commit('SET_COMPANY_MASTERS', res.rows)
        })
    }

}
export default {
    namespaced: true,
    state,
    mutations,
    actions
}